package org.game.module.herobo;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.xiaoleilu.hutool.util.MapUtil;
import org.cfg.AngelSkillTreeCfg;
import org.cfg.DiscreteDataCfg;
import org.cfg.GrowUpCfg;
import org.cfg.HeroCfg;
import org.cfg.HeroProgressCfg;
import org.cfg.cache.AngelSkillTreeCfgCache;
import org.cfg.cache.DiscreteDataCfgCache;
import org.cfg.cache.GrowUpCfgCache;
import org.cfg.cache.HeroCfgCache;
import org.cfg.cache.HeroProgressCfgCache;
import org.constant.*;
import org.error.GameErrorCode;
import org.game.constant.AttrConstant;
import org.game.constant.SessionConstent;
import org.game.db.bean.Hero;
import org.game.db.bean.Player;
import org.game.db.cache.HeroCache;
import org.game.db.cache.ItemCache;
import org.game.db.proxy.bean.HeroProxy;
import org.game.db.proxy.bean.PlayerDataProxy;
import org.game.db.vo.PlayerDataVO.DiscreteVO;
import org.game.db.vo.SkinVO;
import org.game.log.LogAngel;
import org.game.log.LogHero;
import org.game.log.builder.LogDsp;
import org.game.log.dsp.AngelDsp;
import org.game.log.dsp.GoodsDsp;
import org.game.log.dsp.HeroDsp;
import org.game.manager.HeroManager;
import org.game.manager.ItemManager;
import org.game.manager.PlayerManager;
import org.game.module.EnterGameHandler;
import org.game.module.core.Core;
import org.game.msgBuilder.HeroMsgBuilder;
import org.game.msgBuilder.PlayerMsgBuilder;
import org.game.plugin.event.GameEvent;
import org.game.plugin.event.GameEventPlugin;
import org.game.protobuf.c2s.C2SHeroMsg;
import org.game.protobuf.c2s.C2SHeroMsg.HeroAdvance;
import org.game.protobuf.c2s.C2SHeroMsg.HeroCompose;
import org.game.protobuf.c2s.C2SHeroMsg.HeroExpItem;
import org.game.protobuf.c2s.C2SHeroMsg.HeroUpgrade;
import org.game.protobuf.c2s.C2SHeroMsg.ReqAngelAddBit;
import org.game.protobuf.c2s.C2SHeroMsg.ReqAngelReset;
import org.game.protobuf.c2s.C2SHeroMsg.ReqAngelWake;
import org.game.protobuf.c2s.C2SHeroMsg.ReqUpQuality;
import org.game.protobuf.s2c.S2CHeroMsg;
import org.game.protobuf.s2c.S2CHeroMsg.HeroInfo;
import org.game.protobuf.s2c.S2CHeroMsg.HeroInfoList;
import org.game.protobuf.s2c.S2CHeroMsg.HeroUpgradeResult;
import org.game.protobuf.s2c.S2CItemMsg;
import org.game.protobuf.s2c.S2CPlayerMsg.PlayerInfo;
import org.game.protobuf.s2c.S2CShareMsg.ChangeType;
import org.game.protobuf.s2c.S2CShareMsg.RewardsMsg;
import org.game.util.ProtoUnit;

import com.google.common.collect.Maps;
import com.sojoys.artifact.constant.ArtifactErrorCode;
import com.sojoys.artifact.exception.AbstractLogicModelException;
import com.sojoys.artifact.factory.session.ISession;
import com.sojoys.artifact.manager.MessageManager;
import com.sojoys.artifact.tools.ToolError;
import com.sojoys.artifact.tools.ToolList;
import com.sojoys.artifact.tools.ToolMap;

/**
 * @author : DengYing
 * @CreateDate : 2017年8月21日 上午11:34:30
 * @Description ：Please describe this document
 */
public class HeroBOImpl implements HeroBO, EnterGameHandler {

	@Override
	public void enterGame(Player player) {
//		List<Hero> heros = player.getHerosFkPlayerId();
//		for (Hero hero : heros) {
//			HeroManager.me().calAttr(hero);
//		}
	}

	@Override
	public byte[] getHeros(ISession session) throws AbstractLogicModelException {
		Player player = session.getAttr(SessionConstent.PLAYER);
		List<Hero> heros = player.getHerosFkPlayerId();
		HeroInfoList heroInfoList = HeroMsgBuilder.createHeroInfoList(ChangeType.DEFAULT, heros);
		return ProtoUnit.toByte(heroInfoList);
	}

	@Override
	public byte[] heroUpgrade(ISession session,HeroUpgrade heroUpgrade) throws AbstractLogicModelException {
		Player player = session.getAttr(SessionConstent.PLAYER);
		Hero hero = HeroCache.me().getById(Long.valueOf(heroUpgrade.getHeroId()));
		
		ToolError.isAndTrue(GameErrorCode.NOT_FOND_HERO,"英雄未找到", hero==null);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"不属于自己的数据", hero.getPlayerId() != player.getId());
		
		List<HeroExpItem> items = heroUpgrade.getItemsList();
		Map<Integer, Integer> goods = Maps.newHashMap();
		for (HeroExpItem heroExpItem : items) {
			goods.put(heroExpItem.getItemId(), heroExpItem.getNum());
		}
		
		ToolError.isAndTrue(ArtifactErrorCode.PARAM_ERROR,"参数错误",goods.isEmpty());
		
		boolean check = true; 
		
//		check &= ItemManager.checkGoodsType(goods, ItemType.HERO_EXP);
		ToolError.isAndTrue(GameErrorCode.ITEM_TYPE_ERROR,"道具类型不正确",!check);
		
		check &= ItemManager.checkGoodsByCid(player, goods);
		ToolError.isAndTrue(GameErrorCode.ITEM_NOT_ENOUGH,"道具不足",!check);

		LogDsp log = LogDsp.newBuilder(GoodsDsp.HERO_UP).targetTag(hero.getCid());
		
		List<RewardsMsg> rewards = ItemManager.useGoodsByCid(player, hero, null, goods, null,log);
		
		Map<String, Object> in = Maps.newHashMap();
		in.put(EventConditionKey.CONDITION_TYPE, EventConditionType.HERO_UP_LVL_COUNT);
		in.put(EventConditionKey.HERO_CID, hero.getCid());
		GameEvent event = new GameEvent(player, EventType.HERO_CHANGE, in);
		GameEventPlugin.syncSubmit(event);
		
		return ProtoUnit.toByte(HeroUpgradeResult.newBuilder().addAllRewards(rewards).build());
	}

	@Override
	public byte[] heroAdvance(ISession session, HeroAdvance heroAdvance) throws AbstractLogicModelException {
		// 突破消耗 = 配置ID * 100 + 突破等级 + 1
		Player player = session.getAttr(SessionConstent.PLAYER);
		
		Hero hero = HeroCache.me().getById(Long.valueOf(heroAdvance.getHeroId()));
		
		ToolError.isAndTrue(GameErrorCode.NOT_FOND_HERO,"英雄未找到", hero==null);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"不属于自己的数据", hero.getPlayerId() != player.getId());
		
		int growUpId =  hero.getHeroProxy().getConfig().getAttribute() * 100 + hero.getAdvancedLvl() + 1;
		GrowUpCfg growUp = GrowUpCfgCache.me().getById(growUpId);
		
		ToolError.isAndTrue(GameErrorCode.MAX_ADVANCE_LVL,"已达最大进阶等级", growUp==null);
		
		boolean check = true; 
		
		check &= ItemManager.checkGoodsByCid(player, growUp.getConsume());
		ToolError.isAndTrue(GameErrorCode.ITEM_NOT_ENOUGH,"道具不足",!check);
		
		LogDsp log = LogDsp.newBuilder(GoodsDsp.HERO_ADVANCE).targetTag(hero.getCid()).addAttr("oldlvl", hero.getAdvancedLvl());
		
		ItemManager.costGoodsByCid(player, growUp.getConsume(),log, S2CItemMsg.ItemList.newBuilder());
		int oldLvl = hero.getAdvancedLvl();
		hero.setAdvancedLvl(oldLvl + 1);
		hero.update();
		int nowLvl = hero.getAdvancedLvl();
		
		// 触发英雄事件
		Map<String, Object> in = Maps.newHashMap();
		in.put(EventConditionKey.CONDITION_TYPE, EventConditionType.ADVANCED_LVL);
		in.put(EventConditionKey.HERO_CID, hero.getCid());
		in.put(EventConditionKey.OLD_LEVEL, oldLvl);
		in.put(EventConditionKey.NOW_LEVEL, nowLvl);
		GameEvent event = new GameEvent(player, EventType.HERO_CHANGE, in);
		GameEventPlugin.syncSubmit(event);
					
		LogDsp logDsp = LogDsp.newBuilder(HeroDsp.ADVANCE);
		LogHero.me().log(player.getId(), hero.getCid(), oldLvl, nowLvl, logDsp);
		
		// 重新计算英雄属性
		HeroManager.me().calAttr(hero);
		
		HeroInfo heroInfo = HeroMsgBuilder.createHeroInfo(ChangeType.UPDATE, hero);
		player.getPlayerProxy().sendMsg(MessageManager.me().create(HeroBO.sendHero, ProtoUnit.toByte(HeroMsgBuilder.createHeroInfo(ChangeType.UPDATE, hero))));
		return new byte[0];
	}

	@Override
	public byte[] heroCompose(ISession session, HeroCompose heroCompose) throws AbstractLogicModelException {
		Player player = session.getAttr(SessionConstent.PLAYER);

		int heroCid = heroCompose.getHeroCid();
		ToolError.isAndTrue(GameErrorCode.ALREADY_HAVE_HERO,"已有该英雄",player.getPlayerProxy().getHerosByDbId().get(heroCid)!=null);

		HeroCfg heroCfg = HeroCfgCache.me().getById(heroCid);
		ToolError.isAndTrue(ArtifactErrorCode.PARAM_ERROR,"英雄合成，cid错误",heroCfg == null);

		LogDsp log = LogDsp.newBuilder(GoodsDsp.HERO_COMPOSE).targetTag(heroCfg.getId());
		LogDsp cloneLog = log.clone();

		boolean costSuccess = ItemManager.costGoodsByCid(player,heroCfg.getCompose(),log, S2CItemMsg.ItemList.newBuilder());
		
		ToolError.isAndTrue(ArtifactErrorCode.PARAM_ERROR,"英雄合成，碎片扣除失败",!costSuccess);

		ItemManager.me().addGoodsAndPush(player,null,null, MapUtil.of(heroCfg.getId(),1),cloneLog);

		return S2CHeroMsg.HeroCompose.newBuilder().setSuccess(true).build().toByteArray();
	}


	@Override
	public byte[] angelWake(ISession session, ReqAngelWake msg) throws AbstractLogicModelException {
		Player player = session.getAttr(SessionConstent.PLAYER);
		Hero hero = player.getPlayerProxy().getHerosByDbId().get(Long.valueOf(msg.getHeroId()));
		ToolError.isAndTrue(GameErrorCode.NOT_FOND_HERO,"英雄未找到", hero==null);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"不属于自己的数据", hero.getPlayerId() != player.getId());
		int angelLvl = hero.getAngelLvl();
		HeroCfg cfg = hero.getHeroProxy().getConfig();
		
		ToolError.isAndTrue(GameErrorCode.MAX_ANGEL_LVL,"天使已达最大等级", angelLvl > cfg.getAngelWakeCons().size());
		
		Map<Integer, Integer> cons = ToolList.getMap(angelLvl-1, cfg.getAngelWakeCons());
		
		LogDsp log = LogDsp.newBuilder(GoodsDsp.ANGEL_WAKE).targetTag(cfg.getId()).addAttr("lvl", angelLvl);
		
		ItemManager.costGoodsByCid(player, cons,log, S2CItemMsg.ItemList.newBuilder());
		int oldLvl = hero.getAngelLvl();
		hero.setAngelLvl(angelLvl + 1);
		hero.update();
		int nowLvl = hero.getAngelLvl();
		
		Map<String, Object> in = Maps.newHashMap();
		in.put(EventConditionKey.CONDITION_TYPE, EventConditionType.ANGEL_STAR_LVL);
		in.put(EventConditionKey.HERO_CID, hero.getCid());
		in.put(EventConditionKey.OLD_LEVEL, oldLvl);
		in.put(EventConditionKey.NOW_LEVEL, nowLvl);
		GameEvent event = new GameEvent(player, EventType.ITEM_EVENT, in);
		GameEventPlugin.syncSubmit(event);
		
		LogDsp logDsp = LogDsp.newBuilder(AngelDsp.UP_LVL);
		LogAngel.me().log(player.getId(), hero.getCid(), oldLvl, nowLvl, logDsp);
		
		// 重新计算英雄属性
		HeroManager.me().calAttr(hero);
		
		player.getPlayerProxy().sendMsg(MessageManager.me().create(HeroBO.sendHero, ProtoUnit.toByte(HeroMsgBuilder.createHeroInfo(ChangeType.UPDATE, hero))));
		return new byte[0];
	}

	@Override
	public byte[] angelAddBit(ISession session, ReqAngelAddBit msg) throws AbstractLogicModelException {
		AngelSkillTreeCfg cfg = AngelSkillTreeCfgCache.me().getById(msg.getCid());
		ToolError.isAndTrue(ArtifactErrorCode.NOT_FOND_CONFIG,"配置不存在", cfg == null);
		
		Player player = session.getAttr(SessionConstent.PLAYER);
		Hero hero = player.getPlayerProxy().getHerosByDbId().get(Long.valueOf(msg.getHeroId()));
		ToolError.isAndTrue(GameErrorCode.NOT_FOND_HERO,"英雄未找到", hero==null);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"不属于自己的数据", hero.getPlayerId() != player.getId());
		String key = cfg.getSkillType() + "_" + cfg.getPos();
		int nextlvl = ToolMap.getInt(key, hero.getAngel(),0);
		cfg = AngelSkillTreeCfgCache.me().getByHeroIdSkillTypePosLvl(hero.getCid(), cfg.getSkillType(), cfg.getPos(), nextlvl + 1);

		ToolError.isAndTrue(GameErrorCode.MAX_SKILL_ANGEL_ADDBIT, cfg == null);
		int useSkillPiont = hero.getHeroProxy().getAlreadyUseSkillPiont();
		int lastSkillPoint = (hero.getHeroProxy().getAttr().getOrDefault(AttrConstant.ATTR_SKILL_POINT, 0) / 100) - useSkillPiont;
		
		ToolError.isAndTrue(GameErrorCode.ANGEL_SKILL_POINT_LACKING,"天使技能点不足", lastSkillPoint < cfg.getNeedSkillPiont());
		
		int newLvl = cfg.getLvl();
		
		// 检查前置条件
		List<List<Integer>> frontCondition = cfg.getFrontCondition();
		
		// 天使技能加点
		Map<String,Integer> angel = hero.getAngel();
		
		
		// 是否达成
		boolean reach = true;
		for (List<Integer> e : frontCondition) {
			for (Integer conditionId : e) {
				AngelSkillTreeCfg condCfg = AngelSkillTreeCfgCache.me().getById(conditionId);
				int lvl = ToolMap.getInt(condCfg.getSkillType()+"_"+condCfg.getPos(), angel,0);
				if (lvl >= condCfg.getLvl()) {
					// 达成
					reach&=true;
				}else {
					reach&=false;
				}
			}
			// 达成其中一条
			if (reach) {
				break;
			}
		}
		ToolError.isAndTrue(GameErrorCode.ANGEL_SKILL_CONDITION_NOT_SATISFIED,"加点条件不满足", 
				!reach ||
				hero.getLvl() < cfg.getNeedHeroLvl() ||
				hero.getAngelLvl()< cfg.getNeedAngelLvl());
		
		
		angel.put(key, newLvl);
		hero.getHeroProxy().setAlreadyUseSkillPiont(useSkillPiont + cfg.getNeedSkillPiont());
		hero.update();
		
		
		// 重新计算英雄属性
		HeroManager.me().calAttr(hero);
		
		HeroInfo heroInfo = HeroMsgBuilder.createHeroInfo(ChangeType.UPDATE, hero);
		player.getPlayerProxy().sendMsg(MessageManager.me().create(HeroBO.sendHero, ProtoUnit.toByte(HeroMsgBuilder.createHeroInfo(ChangeType.UPDATE, hero))));
		
		return new byte[0];
	}

	@Override
	public byte[] angelReset(ISession session, ReqAngelReset msg) throws AbstractLogicModelException {
		Player player = session.getAttr(SessionConstent.PLAYER);
		Hero hero = player.getPlayerProxy().getHerosByDbId().get(Long.valueOf(msg.getHeroId()));
		ToolError.isAndTrue(GameErrorCode.NOT_FOND_HERO,"英雄未找到", hero==null);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"不属于自己的数据", hero.getPlayerId() != player.getId());
		List<Integer> removeTypes = msg.getSkillTypeList();
		
		Set<String> removeKeys = new HashSet<>();
		
		Map<String, Integer> angel = hero.getAngel();
		boolean needReset = false;
		for (Integer type : removeTypes) {
			for (Entry<String, Integer> e : angel.entrySet()) {
				needReset |= e.getKey().startsWith(type+"_");
				if (needReset) {
					break;
				}
			}
			if (needReset) {
				break;
			}
		}
		
		ToolError.isAndTrue(GameErrorCode.DONT_NEED_TO_RESET,"无需重置", !needReset);
		
		// 取得天使重置离散
		DiscreteDataCfg discreteData = DiscreteDataCfgCache.me().getById(DiscreteDataID.ANGEL_CONFIG);
		Map data = discreteData.getData();
		int limitPlv = ToolMap.getInt(DiscreteDataKey.ANGEL_RESET_LIMIT_PLV, data);
		int freeCount = ToolMap.getInt(DiscreteDataKey.ANGEL_RESET_FREE_COUNT, data);
		Map resetCost = ToolMap.getMap(DiscreteDataKey.ANGEL_RESET_COST, data);
		
		// 如何大于限制等级
		if (player.getLevel() > limitPlv) {
			PlayerDataProxy playerDataProxy = PlayerManager.me().getDataProxy(player);
			DiscreteVO discreteVO = playerDataProxy.getDiscreteVO();
			int resetAngelCount = discreteVO.getResetAngelCount();
			if (resetAngelCount >= freeCount) {
				LogDsp logDsp = LogDsp.newBuilder(GoodsDsp.RESET_ANGEL_SKILL).addAttr("removeTypes", removeTypes.toString());
				ItemManager.costGoodsByCid(player, resetCost, logDsp, S2CItemMsg.ItemList.newBuilder());
			}
			resetAngelCount++;
			discreteVO.setResetAngelCount(resetAngelCount);
			playerDataProxy.save();
		}
		
		int clearUseSkillPiont = 0;
		for (Entry<String, Integer> e : angel.entrySet()) {
			String[] key = e.getKey().split("_");
			int type = Integer.valueOf(key[0]);
			int pos = Integer.valueOf(key[1]);
			int val = e.getValue();
			if (!removeTypes.contains(type)) {
				continue;
			}
			removeKeys.add(e.getKey());
			
			AngelSkillTreeCfg cfg = AngelSkillTreeCfgCache.me().getByHeroIdSkillTypePosLvl(hero.getCid(), type, pos, val);
			clearUseSkillPiont+=cfg.getSumOccupiedSkillPiont();
		}
		HeroProxy HeroProxy = hero.getHeroProxy(); 
		// 归还技能点
		HeroProxy.setAlreadyUseSkillPiont(HeroProxy.getAlreadyUseSkillPiont()-clearUseSkillPiont);
		// 清除等级
		angel.keySet().removeAll(removeKeys);
		hero.update();
		
		// 重新计算英雄属性
		HeroManager.me().calAttr(hero);
		
		PlayerInfo playerBuilder = PlayerMsgBuilder.createPlayerAttrInfo(player);
		player.getPlayerProxy().sendMsg(MessageManager.me().create(Core.getPlayerInfo,ProtoUnit.toByte(playerBuilder)));
		
		HeroInfo heroInfo = HeroMsgBuilder.createHeroInfo(ChangeType.UPDATE, hero);
		player.getPlayerProxy().sendMsg(MessageManager.me().create(HeroBO.sendHero, ProtoUnit.toByte(heroInfo)));
		 
		LogDsp logDsp = LogDsp.newBuilder(AngelDsp.RESET);
		LogAngel.me().log(player.getId(), hero.getCid(), hero.getAngelLvl(), hero.getAngelLvl(), logDsp);
		return new byte[0];
	}

	@Override
	public byte[] upQuality(ISession session, ReqUpQuality msg) throws AbstractLogicModelException {
		// 突破消耗 = 配置ID * 100 + 突破等级 + 1
		Player player = session.getAttr(SessionConstent.PLAYER);
		
		Hero hero = HeroCache.me().getById(Long.valueOf(msg.getHeroId()));
		ToolError.isAndTrue(GameErrorCode.NOT_FOND_HERO,"英雄未找到", hero==null);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"不属于自己的数据", hero.getPlayerId() != player.getId());
		int progressId =  hero.getHeroProxy().getConfig().getAttribute() * 100 + hero.getHeroProxy().getQuality() + 1;
		HeroProgressCfg heroProgress = HeroProgressCfgCache.me().getById(progressId);
		
		ToolError.isAndTrue(GameErrorCode.MAX_QUALITY_LVL,"已达最大进阶等级", heroProgress==null);
		
		boolean check = true; 
		
		check &= ItemManager.checkGoodsByCid(player, heroProgress.getConsume());
		ToolError.isAndTrue(GameErrorCode.ITEM_NOT_ENOUGH,"道具不足",!check);
		
		LogDsp log = LogDsp.newBuilder(GoodsDsp.HERO_UP_QUALITY).targetTag(hero.getCid()).addAttr("oldlvl", hero.getHeroProxy().getQuality());
		
		ItemManager.costGoodsByCid(player, heroProgress.getConsume(),log, S2CItemMsg.ItemList.newBuilder());
		
		int oldLvl = hero.getHeroProxy().getQuality();
		hero.setUpQuality(hero.getUpQuality()+1);
		hero.update();
		int nowLvl = hero.getHeroProxy().getQuality();
		
		LogDsp logDsp = LogDsp.newBuilder(HeroDsp.OFFLINE);
		LogHero.me().log(player.getId(), hero.getCid(), oldLvl, nowLvl, logDsp);
		
		// 重新计算英雄属性
		HeroManager.me().calAttr(hero);
		
		HeroInfo heroInfo = HeroMsgBuilder.createHeroInfo(ChangeType.UPDATE, hero);
		player.getPlayerProxy().sendMsg(MessageManager.me().create(HeroBO.sendHero, ProtoUnit.toByte(heroInfo)));
		return new byte[0];
	}

	@Override
	public byte[] changeHeroSkin(ISession session, C2SHeroMsg.ReqChangeHeroSkin msg) throws AbstractLogicModelException {
		Player player = session.getAttr(SessionConstent.PLAYER);
		long heroId = Long.valueOf(msg.getHeroId());
		long skinId = Long.valueOf(msg.getSkinId());

		Hero hero = HeroCache.me().getById(heroId);
		ToolError.isAndTrue(GameErrorCode.NOT_FOND_HERO,"英雄未找到", hero==null);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"不属于自己的数据", hero.getPlayerId() != player.getId());

		SkinVO skin = (SkinVO) ItemCache.me().getById(skinId);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"skinId错误",skin == null);
		HeroProxy heroProxy = hero.getHeroProxy();
		long beforeSkinId = heroProxy.getSkinVo() == null ? 0 : heroProxy.getSkinVo().getId();
		
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"hero当前skinId = skinId",beforeSkinId == skinId);
		ToolError.isAndTrue(GameErrorCode.CLIENT_PARAM_IS_ERR,"皮肤不属于该hero",!hero.getHeroProxy().checkSkinId(skin.getCid()));

		SkinVO beforeSkin = (SkinVO) ItemCache.me().getById(beforeSkinId);

		HeroManager.me().changeHeroSkin(hero,skin,beforeSkin);

		player.getPlayerProxy().sendMsg(HeroBO.sendHero,HeroMsgBuilder.createHeroInfo(ChangeType.UPDATE,hero));
		return new byte[0];
	}
}
